package com.wy.service;

import com.wy.bean.Brand;
import com.wy.bean.Car;
import com.wy.bean.Shop;
import com.wy.dao.ShopDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ShopServiceImpl implements ShopService {

    @Resource
    private ShopDao shopDao;

    @Override
    public void addBrand(Brand brand) {
        shopDao.addBrand(brand);
    }

    @Override
    public List<Brand> getBrandlist() {
        return shopDao.getBrandlist();
    }

    @Override
    public void addShop(Shop shop) {
        shopDao.addShop(shop);
    }

    @Override
    public List<Shop> getShoplist(String bid) {
        return shopDao.getShoplist(bid);
    }

    @Override
    public void addCar(String sid) {
        //判断购物车是否存在该商品
        Car car1 = shopDao.getCart(sid);
        if(car1 != null){
            shopDao.updateCar(sid);
        }else{
            shopDao.addCar(sid);
        }
    }

    @Override
    public List<Car> getList() {
        return shopDao.getList();
    }
}
